<?php
/*
 * Created on 11 juin 2009
 * Created by Ludovic Reenaers
 * lreenaers@hotmail.com
 *
 *
 * $class = new ReflectionClass('TheClass');
 if ($class->implementsInterface('IInterface'))
 {
 print "Yep!\n";
 }

 */
class LoginFormGenerator extends Generator implements Wrapable{
	protected $children = array();

	public function setChildren($childArray){
		$bool = true;
		foreach ($childArray as $child){
			if (!is_a( $child, "Generator")){
				$bool = false;
			}
		}
		if($bool){
			$this->children = $childArray;
		}else{
			throw new Exception ("Array must only contains Generators.!");
		}
	}
	public function getChildren(){
		return $this->children;
	}
	public function addChild($Child){
		if (is_a($Child, "Generator")){
			array_push($this->children, $Child);
		}else{
			throw new Exception("you can only add Generators.");
		}
	}
	function setUp(){
		if ($_SESSION["USER_BEAN"]->getProfile()->getLabel()<>"anonymous"){
			$mailvalue = $_SESSION["USER_BEAN"]->getEmail();
		}elseif (isset($_COOKIE[$_SESSION['config']->sitename]['email'])) {
			$mailvalue=$_COOKIE[$_SESSION['config']->sitename]['email'];
		}else{
			$mailvalue="";
		}
		$labels = array('{url}','{maillabel}','{pwslabel}','{logbutton}','{register}','{forgot}','{mailinfo}','{pwsinfo}','{rememberme}','{encoding}','{mailvalue}','{ERROR-HERE}','{title}');
		$values = array($_SESSION['config']->controler,$this->translator->mail,$this->translator->pws,$this->translator->login,$this->translator->register,$this->translator->forgotpws,$this->translator->mailinfo,$this->translator->pwsinfo,htmlspecialchars_decode($this->translator->rememberme),$_SESSION['encoding'],$mailvalue,$this->error,$_SESSION['catname']);
		$template = file_get_contents("html/templates/showLogin");
		$this->content .=str_replace($labels,$values,$template);
	}
	function dump(){
		$this->setUp();
		$wraped = "";
			
		foreach ($this->children as $child){

			$wraped.=$child->dump();
		}
		return str_replace("{WRAP-HERE}",$wraped,$this->content);
	}
}

?>
